*
* Represents files in a repository.
*/
+use MediaWiki\MediaWikiServices;
/**
* Base code for files.
$this->fsFile = $this->repo->getLocalReference( $this->getPath() );
$statTiming = microtime( true ) - $starttime;
- RequestContext::getMain()->getStats()->timing(
+ MediaWikiServices::getInstance()->getStatsdDataFactory()->timing(
'media.thumbnail.generate.fetchoriginal', 1000 * $statTiming );
if ( !$this->fsFile ) {
public function generateAndSaveThumb( $tmpFile, $transformParams, $flags ) {
global $wgIgnoreImageErrors;
- $stats = RequestContext::getMain()->getStats();
+ $stats = MediaWikiServices::getInstance()->getStatsdDataFactory();
$handler = $this->getHandler();
// this object exists
$tmpFile->bind( $this );
- RequestContext::getMain()->getStats()->timing(
+ MediaWikiServices::getInstance()->getStatsdDataFactory()->timing(
'media.thumbnail.generate.bucket', 1000 * $buckettime );
return true;
* @throws MWException
*/
function readOnlyError() {
- throw new MWException( get_class( $this ) . ': write operations are not supported' );
+ throw new MWException( static::class . ': write operations are not supported' );
}
/**
}
/**
- * @return array HTTP header name/value map to use for HEAD/GET request responses
+ * @deprecated since 1.30, use File::getContentHeaders instead
*/
function getStreamHeaders() {
+ wfDeprecated( __METHOD__, '1.30' );
+ return $this->getContentHeaders();
+ }
+
+ /**
+ * @return array HTTP header name/value map to use for HEAD/GET request responses
+ * @since 1.30
+ */
+ function getContentHeaders() {
$handler = $this->getHandler();
if ( $handler ) {
- return $handler->getStreamHeaders( $this->getMetadata() );
- } else {
- return [];
+ $metadata = $this->getMetadata();
+
+ if ( is_string( $metadata ) ) {
+ $metadata = MediaWiki\quietCall( 'unserialize', $metadata );
+ }
+
+ if ( !is_array( $metadata ) ) {
+ $metadata = [];
+ }
+
+ return $handler->getContentHeaders( $metadata, $this->getWidth(), $this->getHeight() );
}
+
+ return [];
}
/**